class Solution(object):
    def findSubsequences(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        
        def backTrace(nums, startIndex, path, ans):
            if len(path) > 1:
                ans.append(path[:])
            use_set = set()
            for i in range(startIndex, len(nums)):
                #小于上一个加入的数或者同一层用过了
                if (len(path) > 0 and nums[i] < path[-1]) or (nums[i] in use_set):
                    continue
                path.append(nums[i])
                use_set.add(nums[i])
                backTrace(nums, i+1, path, ans)
                path.pop()
        
        ans = []
        backTrace(nums, 0, [], ans)
        return ans
